<?php

namespace app\api\model;

use app\common\model\BaseModel;

class Article extends BaseModel
{

    /**
     * 获取推荐的文章
     */
    public static function getByRecommend($articleId = 0)
    {
        $where = static::whereOnline();
        $where['recommendswitch'] = ['>', 0];
        if ($articleId) {
            $where['article_id'] = ['<>', $articleId];
        }
        return self::where($where)->order(static::WEIGH_DESC)->select();

    }

    /**
     * 全部文章
     */
    public static function getArticles($size = 20)
    {
        return self::where(static::whereOnline())->order(static::WEIGH_DESC)->paginate($size);
    }

}
